﻿using Blazored.LocalStorage;
using Bookify.Web.DTO.Apartments;
using Bookify.Web.Services.Base;
using Microsoft.Extensions.Options;
using DateOnly = System.DateOnly;

namespace Bookify.Web.Services.Apartments
{
    public class ApartmentCaller: BaseHttpService
    {
        public ApartmentCaller(IClient client, ILocalStorageService localStorageService, IOptions<ServiceOptions> options) : base(client, localStorageService, options)
        {
        }

        

        public async Task<List<ApartmentDto>> GetListAsync()
        {
            var client = await CreateClientAsync();
            DateOnly dateStar = new DateOnly(2020,1,1);
            DateOnly dateEnd = new DateOnly(2025, 1, 1);
            var response = await client.GetFromJsonAsync<List<ApartmentDto>>($"/api/Apartments?startDate={dateStar}&endDate={dateEnd}");           
            return response ?? new();
        }
    }
}
